/* From here on out is custom stuff */

/* marker docs styles */

/* NB(directxman12): The general gist of this is that we use semantic markup
 * for the actual HTML as much as possible, and then use CSS to look pretty and
 * extract the actual relevant information.  Theoretically, this'll let us do
 * stuff like transform the information for different screen widths. */

/* Removes the counter from marker definitions */
dd:has(+ dd)::before,
dd + dd::before {
    content: normal;
}

/* the marker */
.marker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.25em;
}

.marker > dt.name {
    font-weight: bold;
}

/* the target blob */
.marker::before {
    content: "on " attr(data-target);
    padding: 1px 6px;
    border-radius: 20%;
    background: var(--quote-bg);
    margin-left: 0.5em;
    font-weight: normal;
    opacity: 0.75;
    font-size: 0.75em;
    order: 2; /* hack around the ::before's positioning to get it after the line */
}

/* deprecated markers */
.marker.deprecated[data-target] {
    /* use attribute marker for specificity */
    order: 4;
    opacity: 0.65;
}

.marker.deprecated::before {
    content: "deprecated (on " attr(data-target) ")";
    color: red;
}
.marker.deprecated:not([data-deprecated=""])::before {
    content: "use " attr(data-deprecated) " (on " attr(data-target) ")";
    color: red;
}

/* the summary arguments (hidden in non-summary view) */
.marker dd.args {
    margin-left: 0;
    font-family: mono;
    order: 1; /* hack around the ::before's positioning to get it after the line */
}
.marker dl.args.summary {
    display: inline-block;
    margin-bottom: 0;
    margin-top: 0;
}
/* TODO(directxman12): optional */
.marker dl.args.summary dt {
    display: inline-block;
    font-style: inherit;
}
.marker dl.args.summary dt:first-child::before {
    content: ":";
}
.marker dl.args.summary dt::before {
    content: ",";
}
/* hide in non-summary view */
.marker dd.args {
    display: none;
}

/* the description */
.marker dd.description {
    order: 3; /* hack around the ::before's positioning to get it after the line */
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* all arguments */
.marker dl.args dt.argument::after {
    content: "=";
}
.marker dl.args dd.type {
    font-style: italic;
}
.marker .argument {
    display: inline-block;
    margin-left: 0;
}
.marker .argument.type {
    font-size: 0.875em;
}
.marker .literal {
    font-family:
        "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono",
        monospace, monospace;
    font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
}
.marker .argument.type::before {
    content: "‹";
}
.marker .argument.type::after {
    content: "›";
}

/* summary args */
.marker .args.summary .argument.optional {
    opacity: 0.75;
}

/* anonymous marker args */
.marker.anonymous .description details {
    order: 1;
    flex: 1; /* don't cause arg syntax to wrap */
}
.marker.anonymous .description .args {
    order: 0; /* go before the description */

    /* all on a single line */
    margin-top: 0;
    margin-bottom: 0;
    margin-right: 1em;
}
.marker.anonymous .description {
    flex-direction: row;
}
.marker .description dl.args:empty {
    margin-top: 0;
}

.marker .type .slice::before {
    content: "[]";
}

/* description args */
.marker .description dt.argument.optional::before {
    content: "opt";
    padding: 1px 4px;
    border-radius: 20%;
    background: var(--quote-bg);
    opacity: 0.5;
    margin-left: -3em;
    float: left;
}

/* help text */
.marker summary.no-details {
    list-style: none;
}
.marker summary.no-details::-webkit-details-marker {
    display: none;
}

/* summary view */
.markers-summarize:checked ~ dl > .marker dd.args {
    display: inline-block;
}
.markers-summarize:checked ~ dl > .marker dd.description dl.args {
    display: none;
}
.markers-summarize:checked ~ dl > .marker dd.description {
    margin-bottom: 0.25em;
}

input.markers-summarize {
    display: none;
}
label.markers-summarize::before {
    margin-right: 0.5em;
    content: "\25bc";
    display: inline-block;
}
input.markers-summarize:checked ~ label.markers-summarize::before {
    content: "\25b6";
}

/* misc */
/* marker details should be indented to be in line with the summary,
 * which is indented due to the expando
 */
.marker details > p {
    margin-left: 1em;
}

/* sort by target */
.marker[data-target="package"] {
    order: 2;
}
.marker[data-target="type"] {
    order: 1;
}
.marker[data-target="field"] {
    order: 0;
}
.markers {
    display: flex;
    flex-direction: column;
}

/* don't add margin between collapsed code elements and pre blocks */
/* (this just removes all margin around pre, but that's generally fine) */
.literate pre {
    margin: 0;
}
.literate cite.literate-source + * {
    /* a bit of margin against the cite element */
    margin-top: 0.125em;
}

/* Completely hide low-value collapsed sections (license text, imports) */
details.collapse-hide {
    display: none;
}

/* details elements (not markers) */
details.collapse-code > summary {
    width: 100%;
    cursor: pointer;
    display: flex;
    box-sizing: border-box; /* why isn't this the default? :-/ */
}

details.collapse-code > summary::after {
    content: "\25c0";
    float: right;
    font-size: 0.875em;
    color: var(--inline-code-color);
    opacity: 0.8;
}

details.collapse-code[open] > summary::after {
    content: "\25bc";
}

details.collapse-code > summary pre {
    flex: 1;
    box-sizing: border-box; /* why isn't this the default? :-/ */
    margin: inherit;
    padding: 0.25em 0.5em;
}

details.collapse-code > summary pre span::after {
    content: " (hidden)";
    font-size: 80%;
}

details.collapse-code[open] > summary pre span::after {
    content: "";
}

details.collapse-code > summary pre span.collapse-summary::before {
    content: "// ";
}

details.collapse-code > summary pre span::before {
    content: "// ";
}

/* make summary into code a bit nicer looking */
details.collapse-code[open] > summary + pre {
    margin-top: 0;
}

/* get rid of the ugly blue box that makes the summary->code look bad */
details.collapse-code summary:focus {
    outline: none;
    font-weight: bold; /* keep something around for tab users */
}

/* don't show the default expando */
details.collapse-code > summary {
    list-style: none;
}
details.collapse-code > summary::-webkit-details-marker {
    display: none;
}

/* diagrams */

.diagrams {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.diagrams > * {
    margin-left: 1em;
    margin-right: 1em;
    font-size: 160%;
    font-weight: bold;
}

.diagrams object,
.diagrams svg {
    max-width: 100%;
    max-height: 10em; /* force svg height to behave */
}

.diagrams path,
.diagrams polyline,
.diagrams circle {
    stroke: var(--fg);
}

.diagrams path.text {
    fill: var(--fg);
    stroke: none;
}

.diagrams path.text.invert {
    fill: black;
    stroke: none;
}

/* notes */
aside.note {
    border: 1px solid var(--searchbar-border-color);
    border-radius: 3px;
    margin-top: 1em;
}

aside.note > * {
    margin-left: 1em;
    margin-right: 1em;
}

/* note title */
aside.note > h1 {
    border-bottom: 1px solid var(--searchbar-border-color);
    margin: 0;
    padding: 0.5em 1em;
    font-size: 100%;
    font-weight: normal;
    background: var(--quote-bg);
}

/* warning notes */
aside.note.warning > h1 {
    background: var(--warning-note-background-color, #fcf8f2);
}
aside.note.warning > h1::before {
    /* TODO(directxman12): fill in these colors in theme.
     * If you're good with colors, feel free to play around with this
     * in dark mode. */
    content: "!";
    color: var(--warning-note-color, #f0ad4e);
    margin-right: 1em;
    font-size: 100%;
    vertical-align: middle;
    font-weight: bold;
    padding-left: 0.6em;
    padding-right: 0.6em;
    border-radius: 50%;
    border: 2px solid var(--warning-note-color, #f0ad4e);
}

/* literate source citations */
cite.literate-source {
    font-size: 75%;
    font-family:
        "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono",
        monospace, monospace;
}
cite.literate-source::before {
    content: "$ ";
    font-weight: bold;
    font-style: normal;
}

cite.literate-source > a::before {
    content: "vim ";
    font-style: normal;
    color: var(--fg);
}

/* add a bit of extra padding for readability */
.literate pre code {
    padding-top: 0.75em;
    padding-bottom: 0.75em;
}
